﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XingFuStudio.Pioneer.Applications.City.Element {
    /// <summary>
    /// 商业信息实体
    /// </summary>
    public class BusinessInfo : CityElement{
        /// <summary>
        /// 初始化元素自身数据
        /// </summary>
        /// <param name="elementObject"></param>
        public override void InitElement(Dictionary<string, object> elementObject) {
            //调用基类方法
            base.InitElement(elementObject);

            //赋值自身属性
            this.CanHarvest = Convert.ToInt32(elementObject["ustatus"]) == 1 &&
                Convert.ToInt32(elementObject["goodsnum"]) == 0;
            this.CanDeliver = Convert.ToInt32(elementObject["ustatus"]) == 0 &&
                Convert.ToInt32(elementObject["goodsnum"]) == 0;
            object tmpObject = null;
            this.IsShare = elementObject.TryGetValue("love", out tmpObject);
            this.CanReceive = this.IsShare && Convert.ToInt32(elementObject["fdelivergoods"]) > 0;
        }

        /// <summary>
        /// 是否可以收获
        /// </summary>
        public bool CanHarvest {
            get;
            private set;
        }

        /// <summary>
        /// 是否可以投递货物
        /// </summary>
        public bool CanDeliver {
            get;
            set;
        }

        /// <summary>
        /// 是否可以接收好友供货
        /// </summary>
        public bool CanReceive {
            get;
            private set;
        }

        /// <summary>
        /// 是否为好友分店
        /// </summary>
        public bool IsShare {
            get;
            private set;
        }
    }
}
